home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 #2 / Ham Radio 2000 - Volume 2.iso / HAMV2 / TCP_IP / TNOS230S / DELDEP.C < prev    next >
Encoding:
C/C++ Source or Header  |  1997-07-30  |  962 b   |  50 lines

  1. #define NO_TNOSFOPEN
  2. #include "global.h"
  3. #include "hardware.h"
  4. #undef fopen
  5. #undef fclose
  6.  
  7. #ifndef _lint
  8. static char rcsid[] OPTIONAL = "$Id: deldep.c,v 1.10 1997/07/31 00:44:20 root Exp root $";
  9. #endif
  10.  
  11. #define OBJ "o"
  12.  
  13.  
  14. int
  15. main(int argc,char *argv[])
  16. {
  17. int i, found;
  18. FILE *fp;
  19. char buf[512],buf2[512],origname[512],*cp;
  20.  
  21.     if (argc < 3)    {
  22.         printf ("deldep: no files given!\nusage: deldep searchstr <file> [<file> ...]\n");
  23.         return 1;
  24.     }
  25.     for(i=2;i<argc;i++){
  26.         strcpy(buf,argv[i]);
  27.         if((cp = strchr(buf,'.')) == NULL)
  28.             continue;
  29.         strcpy (origname, buf);
  30.         *cp = '\0';
  31.         fp = fopen(argv[i],"r");
  32.         found = 0;
  33.         if (fp)    {
  34.             while(fgets(buf2,512,fp) != NULL){
  35.                 if(strstr(buf2,argv[1]) == 0)
  36.                     continue;
  37.                 found = 1;
  38.                 sprintf (buf2, "%s.%s", buf, OBJ);
  39.                 unlink (buf2);
  40.                 break;
  41.             }
  42.             if (found)
  43.                 printf("%s: deleted %s.%s ...\n", origname, buf, OBJ);
  44.             fclose(fp);
  45.         }
  46.     }
  47.     return 0;
  48. }
  49.  
  50.